package beautiful.butterfly.drds.data_exchange.data_exchange.record.column.column_cast;

import beautiful.butterfly.drds.data_exchange.data_exchange.record.column.BytesColumn;
import beautiful.butterfly.drds.data_exchange.util.Configuration;

import java.io.UnsupportedEncodingException;


class BytesCast
{
    static String encoding = "utf-8";

    static void init(final Configuration configuration)
    {
        BytesCast.encoding = configuration.getString("common.table_column_name_list.encoding",
                BytesCast.encoding);
        return;
    }

    static String asString(final BytesColumn column)
            throws UnsupportedEncodingException
    {
        if (null == column.asBytes())
        {
            return null;
        }

        return new String(column.asBytes(), encoding);
    }
}
